package com.kiliter;

import cn.hutool.core.io.IoUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;


@EnableScheduling
@SpringBootApplication
@EnableAsync
@Slf4j
@EnableMongoRepositories
public class KiliterApplication extends SpringBootServletInitializer {

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
		return application.sources(KiliterApplication.class);
	}

	public static void main(String[] args){
		SpringApplication springApplication = new SpringApplication(KiliterApplication.class);
		ConfigurableEnvironment env = springApplication.run(args).getEnvironment();
		try {
			log.info(IoUtil.read(new ClassPathResource("static/txt/Log.txt").getInputStream()).toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
		log.info("启动完成");
		log.info("启动端口{}，运行环境{}",env.getProperty("server.port"),env.getProperty("spring.profiles.active"));

	}


}
